//
//  LoginView.m
//  豆瓣_精简版
//
//  Created by dllo on 15/11/7.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "LoginView.h"

@implementation LoginView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self creatSubView];
    }
    return self;
}

- (void)creatSubView{
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 130, 100, 30)];
    nameLabel.text = @"用户名:";
    nameLabel.font = [UIFont systemFontOfSize:22];
    [self addSubview:nameLabel];
    
    UILabel *passwordLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 200, 100, 30)];
    passwordLabel.text = @"密码:";
    passwordLabel.font = [UIFont systemFontOfSize:22];
    [self addSubview:passwordLabel];
    
    self.nameTF = [[UITextField alloc]initWithFrame:CGRectMake(130, 130, 200, 30)];
    self.nameTF.borderStyle = UITextBorderStyleRoundedRect;
    self.nameTF.placeholder = @"请输入用户名";
    [self addSubview:self.nameTF];
    
    self.passwordTF = [[UITextField alloc]initWithFrame:CGRectMake(130, 200, 200, 30)];
    self.passwordTF.borderStyle = UITextBorderStyleRoundedRect;
    self.passwordTF.placeholder = @"请输入密码";
    [self addSubview:self.passwordTF];
    
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    button1.frame = CGRectMake(50, 280, 100, 50);
    button1.tag = 1001;
    button1.backgroundColor = [UIColor colorWithRed:0.482 green:0.783 blue:0.160 alpha:1.000];
    [button1 setTitle:@"登陆" forState:UIControlStateNormal];
    [button1 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button1];
    
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    button2.frame = CGRectMake(220, 280, 100, 50);
    button2.tag = 1002;
    button2.backgroundColor = [UIColor colorWithRed:0.548 green:0.592 blue:0.138 alpha:1.000];
    [button2 setTitle:@"注册" forState:UIControlStateNormal];
    [button2 addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:button2];
}

- (void)buttonAction:(UIButton *)but{
    
    if (but.tag == 1001) {
        [self.myDelegate delegateLogin];
    }else{
        [self.myDelegate delegateRegister];
    }
    
}








@end
